<?php
include_once 'conn.php';
//error_reporting(1);
include_once 'clsEssentials.php';

$action= $_REQUEST['action'];

if($action=="change-password")
{
	$newPassword = sha1(addslashes($_REQUEST['newPassword']));
	$hdnUserName = addslashes($_REQUEST['hdnUserName']);
	$sql = "UPDATE tbl_users SET password='$newPassword' WHERE user_name='$hdnUserName'";
	$run = mysql_query($sql);
	if($run)
		echo 1;
	else
		echo 0;
}
else if($action=="change-number")
{
	$txtContactNumber = addslashes($_REQUEST['txtContactNumber']);
	$sql = "UPDATE tbl_item_details SET item_value='$txtContactNumber' WHERE item_name='contact-number'";
	$run = mysql_query($sql);
	if($run)
		echo 1;
	else
		echo 0;
}
else if($action=="change-email")
{
	$txtContactEmail = addslashes($_REQUEST['txtContactEmail']);
	$sql = "UPDATE tbl_item_details SET item_value='$txtContactEmail' WHERE item_name='contact-email'";
	$run = mysql_query($sql);
	if($run)
		echo 1;
	else
		echo 0;
}
else if($action=="add-feedback")
{
	$txtCusName = addslashes($_REQUEST['txtCusName']);
	$txtCusCountry = addslashes($_REQUEST['txtCusCountry']);
	$selectGender = $_REQUEST['selectGender'];
	$txtAreaFeedback = $_REQUEST['txtAreaFeedback'];
	$sql = "INSERT INTO tbl_customer_feedback (cus_name,cus_country,cus_feedback,cus_gender,publish)
			VALUES ('".$txtCusName."','".$txtCusCountry."','".$txtAreaFeedback."','".$selectGender."','Y')";
	$run = mysql_query($sql);
	if($run)
		echo 1;
	else
		echo 0;
}
else if($action=="update-package")
{
	$id = addslashes($_REQUEST['id']);
	$txtadditionalpc = addslashes($_REQUEST['txtadditionalpc']);
	$txtpcs = addslashes($_REQUEST['txtpcs']); 
	$txtplans= addslashes($_REQUEST['txtplans']); 
	$txtprice= addslashes($_REQUEST['txtprice']); 
	$txtvalidity= addslashes($_REQUEST['txtvalidity']); 
	
	$sql = "UPDATE tbl_package_details 
			SET additionalpc='".$txtadditionalpc."',pcs='".$txtpcs."',plans='".$txtplans."',price='".$txtprice."',validity='".$txtvalidity."'
			WHERE id=".$id;
	$run = mysql_query($sql);
	if($run)
		echo 1;
	else
		echo 0;
}
else if($action=="add-package")
{
	$txtadditionalpc = addslashes($_REQUEST['txtadditionalpc']);
	$txtpcs = addslashes($_REQUEST['txtpcs']); 
	$txtplans= addslashes($_REQUEST['txtplans']); 
	$txtprice= addslashes($_REQUEST['txtprice']); 
	$txtvalidity= addslashes($_REQUEST['txtvalidity']); 
	
	$sql = "INSERT INTO tbl_package_details (plans,price,validity,pcs,additionalpc,is_active) 
			VALUES('".$txtplans."','".$txtprice."','".$txtvalidity."','".$txtpcs."','".$txtadditionalpc."','Y')";
	
	$run = mysql_query($sql);
	if($run)
		echo 1;
	else
		echo 0;
}
else if($action=="delete-package")
{
	$id = addslashes($_REQUEST['id']);
	
	$sql = "UPDATE tbl_package_details SET is_active = 'N' WHERE id=".$id;
	$run = mysql_query($sql);
	if($run)
		echo 1;
	else
		echo 0;
}